<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    请输入你的年龄：<input type="text" id="age"><br>
    <input type="text" id="result">
    <script>
        //获取文本对象框
        var ageObj=document.getElementById("age")
        var resultObj=document.getElementById("result")
        //获取输入age值
        ageObj.onblur=function(){
        var age=parseInt(ageObj.value)
        if(age>=18){
            resultObj.value="已成年"
        }else{
            resultObj.value="未成年"
        }
    }
    </script>
</body>
</html>